package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Classcardservice.ClassCardService;
import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.entity.EvaluationLabel;
import com.wuseguang.springcloud.entity.ExaminationRoom;
import com.wuseguang.springcloud.service.ExaminationRoomService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 考场表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-04-28
 */
@RestController
@RequestMapping("/examinationRoom")
public class ExaminationRoomController {


    private Logger logger  = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private ExaminationRoomService examinationRoomServiceImpl;


    /**
     * 添加考场
     * @param request
     * @param examinationRoom
     * @return
     */
    @RequestMapping("/addExaminationRoom")
    public Result addExaminationRoom(RequestParameterWrapper request,  ExaminationRoom examinationRoom){

        logger.info("添加考场");
        //教师id
        String teacherId = request.getParam("teacherId");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        examinationRoom.setSchoolId(Integer.valueOf(schoolId));
        return examinationRoomServiceImpl.addExaminationRoom(examinationRoom,teacherId);
    }

    /**
     * 查询考场信息
     * @param request
     * @return
     */
    @RequestMapping("/findExaminationRoom")
    public Result findExaminationRoom(RequestParameterWrapper request,
                                      @RequestParam(value = "name",required = false,defaultValue = "") String name){
        logger.info("查询考场信息");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        //教师id
        String teacherId = request.getParam("teacherId");
        return examinationRoomServiceImpl.findExaminationRoom(schoolId,teacherId,name);
    }

    /**
     * 删除考场信息
     * @param request
     * @param id 考场id
     * @return
     */
    @RequestMapping("/delteExaminationRoom")
    public Result delteExaminationRoom(RequestParameterWrapper request,@RequestParam("id") Integer id){
        logger.info("删除考场信息");
        return examinationRoomServiceImpl.delteExaminationRoom(id);
    }

    /**
     * 开启考场模式
     * @param request
     * @param id 考场id
     * @param pattern 考场状态 0未开启考场模式，1已开启考场模式
     * @return
     */
    @RequestMapping("/openTheExaminationRoom")
    public Result openTheExaminationRoom(RequestParameterWrapper request,
                                         @RequestParam("id") Integer id,
                                         @RequestParam("pattern") Integer pattern){
        logger.info("开启考场模式");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        //获取所有教室推送
        List<Integer> list = examinationRoomServiceImpl.openTheExaminationRoom(id,pattern,schoolId);

        return new Result();
    }

}

